<!DOCTYPE html>
<html>
	<head>
		<include file="public:meta" />
		<link rel="stylesheet" href="../public/css/company.css">
		<link rel="stylesheet" href="../public/css/nprogress.css">
	</head>
	<body>
		<include file="public:header"/>
		<div class="split-block"></div>
		<if condition="$Think.get.anew eq 1 or $company_profile['audit'] eq '0'">
			<form id="J_auth" action="{:U('company/com_auth')}" method="post">
				<div class="list_height plist-txt notarrow">
				  <div class="pic"></div>
				  <div class="tit font14">企业全称</div>
				  <div class="describe font12">
				  	<input name="companyname" type="text" placeholder="请输入企业全称" value="{$company_profile.companyname}">
				  </div>
				  <div class="arrow"></div>
				  <div class="clear"></div>
				</div>
				
				<div class="list_height plist-txt notarrow">
				  <div class="pic"></div>
				  <div class="tit font14">注册号</div>
				  <div class="describe font12"><input name="license" type="text" placeholder="请输入营业执照注册号" value="{$company_profile.license}"></div>
				  <div class="arrow"></div>
				  <div class="clear"></div>
				</div>	

				<div class="list_height plist-txt notarrow">
				  <div class="pic"></div>
				  <div class="tit font14">法人代表</div>
				  <div class="describe font12"><input name="legal_person" type="text" placeholder="请输入公司法人姓名" value="{$company_profile.legal_person}"></div>
				  <div class="arrow"></div>
				  <div class="clear"></div>
				</div>
				<div class="list_height plist-txt notarrow">
				  <div class="pic"></div>
				  <div class="tit font14">营业执照</div>
				  <div class="describe com_auth_add_btn font13">
				  	<div class="qs-btn qs-btn-inline qs-btn-green qs-btn-medium mt125">
						  <span class="js-up-txt">上传营业执照</span>
						  <input type="file" id="browseFile" class="browseFile">
					  </div>
				  	<input type="hidden" id="certificate_img_up" name="certificate_img_up" value="<if condition="$Think.get.anew eq ''">{:attach($company_profile['certificate_img'],'certificate_img')}</if>">
				  </div>

				  <div class="arrow"></div>
				  <div class="clear"></div>
				</div>
				<div class="split-block"></div>
				<div class="qs-center m-auth-img-box-group qs-hidden"><div class="m-auth-img-box"></div></div>
				<div class="btn-spacing">
					<a id="save_info" href="javascript:;" class="qs-btn qs-btn-blue font18">提交认证资料</a>
				</div>
			</form>
		<else/>
			<switch name="company_profile['audit']">
				<case value="1">
					<!--审核通过-->
					<div class="set-success-tip-box qs-center">
			            <div class="set-success-tip success font16">审核通过!</div>
			        </div>
			        <div class="qs-center font13 txt-color-9 mt2">恭喜您，您提交的营业执照通过审核了！</div>
				</case>
				<case value="2">
					<!--等待审核-->
					<div class="set-success-tip-box qs-center">
			            <div class="set-success-tip wait font16">认证资料已提交，等待审核中!</div>
			        </div>
			        <div class="qs-center font13 txt-color-9 mt2">我们会在1个工作日内审核您的资料，请耐心等待！</div>
				</case>
				<case value="3">
					<!--审核不通过-->
					<div class="set-success-tip-box qs-center">
			            <div class="set-success-tip failure font16">审核不通过!</div>
			        </div>
			        <div class="qs-center font13 txt-color-9 mt2">您好，您提交的企业认证资料未通过审核！</div>
			        <div class="btn-spacing mt10"><a href="{:U('company/com_auth',array('anew'=>1))}" class="qs-btn qs-btn-blue font18">重新认证</a></div>
				</case>
			</switch>
		</if>
		<include file="public:footer_min" />
		<script src="../public/js/mobileBUGFix.mini.js"></script>
		<script src="../public/js/LocalResizeIMG.js"></script>
		<script src="../public/js/nprogress.js"></script>
		<script type="text/javascript">
			$('#browseFile').localResizeIMG({
	            width: 400,
	            quality: 1,
	            success: function (result) {  
	                var submitData={
	                    base64_string:result.clearBase64
	                };
		              NProgress.start();
	                $.ajax({
	                    type: "POST",
	                    url: "{:U('upload/certificate_img')}",
	                    data: submitData,
	                    dataType:"json",
	                    success: function(result){
		                      NProgress.done();
	                        if(result.status == 1){
	                            $('#certificate_img_up').val(result.data.img);
								$('.m-auth-img-box').html('<img src="' + result.data.path + '">');
								$('.m-auth-img-box-group').removeClass('qs-hidden');
								$('.js-up-txt').text('重新选择');
	                        }else{
	                            qsToast({type:2,context:result.msg});
	                        }
	                    }, 
	                    complete :function(XMLHttpRequest, textStatus){},
	                    error:function(XMLHttpRequest, textStatus, errorThrown){ //上传失败 
	                        qsToast({type:2,context: '营业执照上传失败！'});
	                    }
	                }); 
	            }
	        });
			$("#save_info").die().live('click',function(){
	            var companyname = $.trim($("input[name=companyname]").val());
	            var license = $.trim($("input[name=license]").val());
	            var legal_person = $.trim($("input[name=legal_person]").val());
	            var certificate_img_up = $.trim($("input[name=certificate_img_up]").val());
	            var id = "{$company_profile['id']}";
	            if (companyname == "") {
	                qsToast({type:2,context: '请填写企业名称'});
	                return false;
	            }
	            if (license == "") {
	                qsToast({type:2,context: '请输入营业执照注册号'});
	                return false;
	            }
	            if (!legal_person) {
	                qsToast({type:2,context: '法人代表'});
	                return false;
	            }
	            if (certificate_img_up == "") {
	                qsToast({type:2,context: '请上传营业执照'});
	                return false;
	            }
	            $(this).html('正在保存...');
	            $(this).addClass('qs-btn-border-disabled');
	            $('#J_auth').submit();
	        });
		</script>
	</body>
</html>